package com.bfg.model;

public class Main {
	static int cnt=0;
	static boolean less(double v, double w){
		cnt++;
		return v<w;
	}
	
	static void exch(double[] a, int i, int j){
		double temp=a[i];
		a[i]=a[j];
		a[j]=temp;
	}
	
	static void compExch(double[] a, int i, int j){
		if(less(a[j],a[i]))
			exch(a, i, j);
	}
	
	static void sort(double[] a, int min, int max){
		for(int i=min+1;i<=max;i++)
			for(int j=i;j>min;j--)
				compExch(a, j-1, j);
	}
	
	static void selection(double[] a, int min, int max){
		for(int i=min;i<max;i++)
			for(int j=i+1;j<=max;j++)
				compExch(a, i, j);
	}
	
	static void insertion(double[] a, int min, int max){
		for(int i=max;i>min;i--) {
			compExch(a, i-1, i);
		}
		for(int i=min+2;i<=max;i++) {
			int j=i;
			double temp=a[i];
			while(less(temp, a[j-1])) {
				a[j]=a[j-1];
				j--;
			}
			a[j]=temp;
		}
	}
	
	static void bubble(double[] a, int min, int max){
		for(int i=0;i<max;i++)
			for(int j=max;j>i;j--)
				compExch(a, j-1, j);
	}
	
	static boolean matchLetter(char[] a, char b) {
		boolean find = false;
		for(int i=0;i<a.length;i++) {
			if(a[i]==b)
				find=true;
		}
		return find;
	}
	public static void main(String[] args) {
//		Integer arr_number[]={1,2,3,4,5,6,7,8,9,10};
//		char arr_char[]={'e','k','o'};
		String str="THISISJUSTFOREXAMPLES";
		int N=10;
		double a[] = new double[N]; 
        for (int i = 0; i < N; i++) 
          a[i] = 100*Math.random();
        for (int i = 0; i < N; i++) 
            System.out.println(a[i] + ""); 
        System.out.println("Compares used: " + cnt); 
//        sort(a, 0, N-1); 
//        selection(a, 0, N-1);
//        insertion(a, 0, N-1);
        bubble(a, 0, N-1);
        if (N < 100) 
          for (int i = 0; i < N; i++) 
            System.out.println(a[i] + ""); 
        System.out.println("Compares used: " + cnt); 
        char arr_char[]=str.toCharArray();
        char arr_result[]=new char[arr_char.length];
        int count=0;
        for(int i=0;i<arr_char.length;i++) {
        	if(!matchLetter(arr_result, arr_char[i])) {
        		arr_result[count]=arr_char[i];
        		count++;
        	}
        }
        System.out.println(count);
        for(int i=0;i<arr_result.length;i++) {
            if(arr_result[i]!=0)
            	System.out.println(arr_result[i]);
        }
	}
}
